﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace RPGMapa.Data
{
    [Serializable()]
    public class Vector2
    {
        int x, y;

        public int Y
        {
            get { return y; }
            set { y = value; }
        }
        public int X
        {
            get { return x; }
            set { x = value; }
        }


        public Vector2()
        {
            this.x = 0;
            this.y = 0;
        }
        public Vector2(int x, int y)
        {
            this.x = x;
            this.y = y;
        }

        public Vector2(float x, float y)
        {
            this.x = (int)x;
            this.y = (int)y;
        }
        public Vector2(double x, double y)
        {
            this.x = (int)x;
            this.y = (int)y;
        }
        public Vector2(Size s)
        {
            this.x = s.Width;
            this.y = s.Height;
        }
        public Vector2(Point p)
        {
            this.x = p.X;
            this.y = p.Y;
        }


        public static implicit operator Size(Vector2 v)
        {
            return new Size((int)v.X, (int)v.Y);
        }
        public static implicit operator Point(Vector2 v)
        {
            return new Point((int)v.X, (int)v.Y);
        }

        public static Vector2 operator +(Vector2 left, Vector2 right)
        {
            return new Vector2(left.X + right.X, left.Y + right.Y);
        }
        public static Vector2 operator -(Vector2 left, Vector2 right)
        {
            return new Vector2(left.X - right.X, left.Y - right.Y);
        }
        public static Vector2 operator *(Vector2 left, Vector2 right)
        {
            return new Vector2(left.X * right.X, left.Y * right.Y);
        }
        public static Vector2 operator /(Vector2 left, Vector2 right)
        {
            return new Vector2(left.X / right.X, left.Y / right.Y);
        }
        public static Vector2 operator %(Vector2 left, Vector2 right)
        {
            return new Vector2(left.X % right.X, left.Y % right.Y);
        }

        public override string ToString()
        {
            return X.ToString() + ", " + Y.ToString();
        }


        public static Vector2 Zero()
        {
            return new Vector2(0, 0);
        }
        public static Vector2 Unit()
        {
            return new Vector2(1, 1);
        }
    }
}
